using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Portal.User.Security;

namespace Portal.GUI.EditoralOffice.MainOffce.Menu
{
    public partial class LeftMenu : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadProfile();
            Control ctrMenu = LoadControl("Menu.ascx");
            plcMenu.Controls.Add(ctrMenu);
            ctrMenu = LoadControl("ProfileMenu.ascx");
            plcProfile.Controls.Add(ctrMenu);
        }
        private void LoadProfile()
        {
            MainSecurity objSecu = new MainSecurity();
            Role objPermis = objSecu.GetRole(Page.User.Identity.Name, Portal.API.Config.CurrentChannel);

            if (objPermis.isPhongVien)
            {
                tr_pv.Visible = true;
                tr_pv1.Visible = true;
                tr_pv2.Visible = true;
                box_pv.Attributes.Remove("class");
                box_pv.Attributes.Add("class", "Menuleft_ContentBox");
            }

            if (objPermis.isThuKyToaSoan || objPermis.isTongBienTap || objPermis.isPhuTrachKenh)
            {
                tr_tkts.Visible = true;
                tr_tkts1.Visible = true;
                tr_tkts2.Visible = true;
                box_tkts.Attributes.Remove("class");
                box_tkts.Attributes.Add("class", "Menuleft_ContentBox");
            }
            //if (objPermis.isPhongVien || objPermis.isTongBienTap)
            //{
            //    tr_pv.Visible = true;
            //    tr_pv1.Visible = true;
            //    tr_pv2.Visible = true;
            //    box_pv.Attributes.Remove("class");
            //    box_pv.Attributes.Add("class", "Menuleft_ContentBox");
            //}

            if (objPermis.isBienTapVien || objPermis.isTongBienTap || objPermis.isPhuTrachKenh)
            {
                tr_btv.Visible = true;
                tr_btv1.Visible = true;
                tr_btv2.Visible = true;
                box_btv.Attributes.Remove("class");
                box_btv.Attributes.Add("class", "Menuleft_ContentBox");
            }

            if (objPermis.isThuKyChuyenMuc || objPermis.isTongBienTap || objPermis.isPhuTrachKenh)
            {
                tr_tkm.Visible = true;
                tr_tkm1.Visible = true;
                tr_tkm2.Visible = true;
                box_tkm.Attributes.Remove("class");
                box_tkm.Attributes.Add("class", "Menuleft_ContentBox");
            }

            if (objPermis.isThuKyChuyenMuc || objPermis.isTongBienTap || objPermis.isPhuTrachKenh || objPermis.isBienTapVien || objPermis.isThuKyToaSoan)
            {
                tr_qlstat.Visible = true;
                tr_qlstat1.Visible = true;
                tr_qlstat2.Visible = true;


            }

            #region Check ProFile Menu
            /*if (objPermis.isPhuTrachKenh)
            {
                tblMain.Rows[0].Visible = false;
                tblMain.Rows[1].Visible = false;
                tblMain.Rows[2].Visible = false;

                tblMain.Rows[3].Visible = false;
                tblMain.Rows[4].Visible = false;
                tblMain.Rows[5].Visible = false;

                tblMain.Rows[6].Visible = false;
                tblMain.Rows[7].Visible = false;
                tblMain.Rows[8].Visible = false;

                tblMain.Rows[9].Visible = false;
                tblMain.Rows[10].Visible = false;
                tblMain.Rows[11].Visible = false;

                tblMain.Rows[12].Visible = true;
                tblMain.Rows[13].Visible = true;
                tblMain.Rows[14].Visible = true;

                tblMain.Rows[13].Cells[0].Attributes.Remove("class");
                tblMain.Rows[13].Cells[0].Attributes.Add("class", "Menuleft_ContentBox");
            }
            if (objPermis.isThuKyToaSoan)
            {
                tblMain.Rows[0].Visible = false;
                tblMain.Rows[1].Visible = false;
                tblMain.Rows[2].Visible = false;

                tblMain.Rows[3].Visible = false;
                tblMain.Rows[4].Visible = false;
                tblMain.Rows[5].Visible = false;

                tblMain.Rows[6].Visible = false;
                tblMain.Rows[7].Visible = false;
                tblMain.Rows[8].Visible = false;

                tblMain.Rows[9].Visible = true;
                tblMain.Rows[10].Visible = true;
                tblMain.Rows[11].Visible = true;

                tblMain.Rows[12].Visible = false;
                tblMain.Rows[13].Visible = false;
                tblMain.Rows[14].Visible = false;

                tblMain.Rows[10].Cells[0].Attributes.Remove("class");
                tblMain.Rows[10].Cells[0].Attributes.Add("class", "Menuleft_ContentBox");
            }
            if (objPermis.isThuKyChuyenMuc)
            {
                tblMain.Rows[0].Visible = false;
                tblMain.Rows[1].Visible = false;
                tblMain.Rows[2].Visible = false;

                tblMain.Rows[3].Visible = false;
                tblMain.Rows[4].Visible = false;
                tblMain.Rows[5].Visible = false;

                tblMain.Rows[6].Visible = true;
                tblMain.Rows[7].Visible = true;
                tblMain.Rows[8].Visible = true;

                tblMain.Rows[9].Visible = false;
                tblMain.Rows[10].Visible = false;
                tblMain.Rows[11].Visible = false;

                tblMain.Rows[12].Visible = false;
                tblMain.Rows[13].Visible = false;
                tblMain.Rows[14].Visible = false;

                tblMain.Rows[7].Cells[0].Attributes.Remove("class");
                tblMain.Rows[7].Cells[0].Attributes.Add("class", "Menuleft_ContentBox");
            }
            if (objPermis.isBienTapVien)
            {
                tblMain.Rows[0].Visible = false;
                tblMain.Rows[1].Visible = false;
                tblMain.Rows[2].Visible = false;

                tblMain.Rows[3].Visible = true;
                tblMain.Rows[4].Visible = true;
                tblMain.Rows[5].Visible = true;

                tblMain.Rows[6].Visible = false;
                tblMain.Rows[7].Visible = false;
                tblMain.Rows[8].Visible = false;

                tblMain.Rows[9].Visible = false;
                tblMain.Rows[10].Visible = false;
                tblMain.Rows[11].Visible = false;

                tblMain.Rows[12].Visible = false;
                tblMain.Rows[13].Visible = false;
                tblMain.Rows[14].Visible = false;

                tblMain.Rows[4].Cells[0].Attributes.Remove("class");
                tblMain.Rows[4].Cells[0].Attributes.Add("class", "Menuleft_ContentBox");
            }
            if (objPermis.isPhongVien)
            {
                tblMain.Rows[0].Visible = true;
                tblMain.Rows[1].Visible = true;
                tblMain.Rows[2].Visible = true;

                tblMain.Rows[3].Visible = false;
                tblMain.Rows[4].Visible = false;
                tblMain.Rows[5].Visible = false;

                tblMain.Rows[6].Visible = false;
                tblMain.Rows[7].Visible = false;
                tblMain.Rows[8].Visible = false;

                tblMain.Rows[9].Visible = false;
                tblMain.Rows[10].Visible = false;
                tblMain.Rows[11].Visible = false;

                tblMain.Rows[12].Visible = false;
                tblMain.Rows[13].Visible = false;
                tblMain.Rows[14].Visible = false;

                tblMain.Rows[1].Cells[0].Attributes.Remove("class");
                tblMain.Rows[1].Cells[0].Attributes.Add("class", "Menuleft_ContentBox");
            }*/
            #endregion
        }
    }
}